<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用jquery的方式来实现ajax</title>
</head>
<body>
     <form autocomplete="off">
        姓名:<input type="text" id="username">
         <span id="uSpan"></span>
         <br>
         <input type="submit" value="注册">
     </form>
</body>
<script src="js/jquery-3.3.1.min.js"></script>
<script>
    //给input标签设置一个消失焦点事件
    $("#username").blur(function(){
        //获取username中的值
       var username = $("#username").val();
       $.get(
           "userServlet",
           "username="+ username,
           function (date) {
               $("#uSpan").html(date);
           },
           "text"
       );
    });
</script>
</html>